﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Model;

namespace FubiManger.Pad
{
    ////ToolboxItem用于控制是否添加自定义控件到工具箱，true添加，false不添加
    //[System.ComponentModel.ToolboxItem(true)]
    partial class Write_offcontrol : Smobiler.Core.Controls.MobileUserControl
    {
        public Write_offcontrol() : base()
        {
            //This call is required by the SmobilerUserControl.
            InitializeComponent();
        }
        ms_order ord = new ms_order();
        /// <summary>
        /// 商户ID
        /// </summary>
        public string merchantid { get; set; }
        private void btnclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnquery_Press(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtordsn.Text))
            {
                ord = orderDal.Querybysn(txtordsn.Text);
                if (ord.codestatus == "1" && ord.merchant_id == merchantid)
                {
                    btnoff.Enabled = true;
                    lbltxt.Text = "该订单可以核销";
                }
                else
                {
                    lbltxt.Text = "该订单无需核销";
                }
            }
        }
        /// <summary>
        /// 核销
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnoff_Press(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtordsn.Text))
            {                
                orderDal.Updatecodestatusscan(txtordsn.Text);
                this.Close();
            }
        }
    }
}